/*   1:    */ package org.jetbrains.java.debugger.breakpoints;
/*   2:    */ 
/*   3:    */

import com.intellij.debugger.InstanceFilter;
import com.intellij.debugger.ui.breakpoints.EditClassFiltersDialog;
import com.intellij.debugger.ui.breakpoints.EditInstanceFiltersDialog;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.psi.PsiClass;
import com.intellij.ui.FieldPanel;
import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.ui.XBreakpointCustomPropertiesPanel;
import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */
/*  14:    */
/*  15:    */
/*  16:    */
/*  17:    */
/*  18:    */
/*  19:    */
/*  20:    */
/*  21:    */
/*  22:    */
/*  23:    */
/*  24:    */
/*  25:    */
/*  26:    */
/*  27:    */
/*  28:    */
/*  29:    */
/*  30:    */
/*  31:    */ 
/*  32:    */ public class JavaBreakpointFiltersPanel<T extends JavaBreakpointProperties, B extends XBreakpoint<T>>
/*  33:    */   extends XBreakpointCustomPropertiesPanel<B>
/*  34:    */ {
/*  35:    */   private JPanel a;
/*  36:    */   private JPanel b;
/*  37:    */   private JCheckBox c;
/*  38:    */   private JPanel d;
/*  39:    */   private JPanel e;
/*  40:    */   private JCheckBox f;
/*  41:    */   private JPanel g;
/*  42:    */   private JPanel h;
/*  43:    */   private JCheckBox i;
/*  44:    */   private JTextField j;
/*  45:    */   private final FieldPanel k;
/*  46:    */   private final FieldPanel l;
/*  47: 62 */   private com.intellij.ui.classFilter.ClassFilter[] m = com.intellij.ui.classFilter.ClassFilter.EMPTY_ARRAY;
/*  48: 63 */   private com.intellij.ui.classFilter.ClassFilter[] n = com.intellij.ui.classFilter.ClassFilter.EMPTY_ARRAY;
/*  49: 64 */   private InstanceFilter[] o = InstanceFilter.EMPTY_ARRAY;
/*  50:    */   protected final Project myProject;
/*  51:    */   private PsiClass p;
/*  52:    */   
/*  53:    */   public JavaBreakpointFiltersPanel(Project paramProject)
/*  54:    */   {
/*  55: 70 */     this.myProject = paramProject;
/*  56: 71 */     c();this.k = new FieldPanel(new MyTextField(), "", null, new ActionListener()
/*  57:    */     {
/*  58:    */       public void actionPerformed(ActionEvent paramAnonymousActionEvent)
/*  59:    */       {
/*  60: 75 */         JavaBreakpointFiltersPanel.this.b();
/*  61: 76 */         EditInstanceFiltersDialog localEditInstanceFiltersDialog = new EditInstanceFiltersDialog(JavaBreakpointFiltersPanel.this.myProject);
/*  62: 77 */         localEditInstanceFiltersDialog.setFilters(JavaBreakpointFiltersPanel.this.o);
/*  63: 78 */         localEditInstanceFiltersDialog.show();
/*  64: 79 */         if (localEditInstanceFiltersDialog.getExitCode() == 0)
/*  65:    */         {
/*  66: 80 */           JavaBreakpointFiltersPanel.this.o = localEditInstanceFiltersDialog.getFilters();
/*  67: 81 */           JavaBreakpointFiltersPanel.this.a(true);
/*  68:    */         }
/*  69:    */       }
/*  70: 81 */     }, null);
/*  71:    */     
/*  72:    */ 
/*  73:    */ 
/*  74:    */ 
/*  75:    */ 
/*  76:    */ 
/*  77: 88 */     this.l = new FieldPanel(new MyTextField(), "", null, new ActionListener()
/*  78:    */     {
/*  79:    */       public void actionPerformed(ActionEvent paramAnonymousActionEvent)
/*  80:    */       {
/*  81: 92 */         JavaBreakpointFiltersPanel.this.a();
/*  82:    */         
/*  83: 94 */         com.intellij.ide.util.ClassFilter localClassFilter = JavaBreakpointFiltersPanel.this.createClassConditionFilter();
/*  84:    */         
/*  85: 96 */         EditClassFiltersDialog localEditClassFiltersDialog = new EditClassFiltersDialog(JavaBreakpointFiltersPanel.this.myProject, localClassFilter);
/*  86: 97 */         localEditClassFiltersDialog.setFilters(JavaBreakpointFiltersPanel.this.m, JavaBreakpointFiltersPanel.this.n);
/*  87: 98 */         localEditClassFiltersDialog.show();
/*  88: 99 */         if (localEditClassFiltersDialog.getExitCode() == 0)
/*  89:    */         {
/*  90:100 */           JavaBreakpointFiltersPanel.this.m = localEditClassFiltersDialog.getFilters();
/*  91:101 */           JavaBreakpointFiltersPanel.this.n = localEditClassFiltersDialog.getExclusionFilters();
/*  92:102 */           JavaBreakpointFiltersPanel.this.b(true);
/*  93:    */         }
/*  94:    */       }
/*  95:102 */     }, null);
/*  96:    */     
/*  97:    */ 
/*  98:    */ 
/*  99:    */ 
/* 100:    */ 
/* 101:    */ 
/* 102:109 */     ActionListener local3 = new ActionListener()
/* 103:    */     {
/* 104:    */       public void actionPerformed(ActionEvent paramAnonymousActionEvent)
/* 105:    */       {
/* 106:112 */         JavaBreakpointFiltersPanel.this.updateCheckboxes();
/* 107:    */       }
/* 108:115 */     };
/* 109:116 */     this.i.addActionListener(local3);
/* 110:117 */     this.c.addActionListener(local3);
/* 111:118 */     this.f.addActionListener(local3);
/* 112:    */     
/* 113:120 */     ToolTipManager.sharedInstance().registerComponent(this.l.getTextField());
/* 114:121 */     ToolTipManager.sharedInstance().registerComponent(this.k.getTextField());
/* 115:    */     
/* 116:123 */     a(this.d, this.k);
/* 117:124 */     a(this.g, this.l);
/* 118:    */     
/* 119:126 */     DebuggerUIUtil.focusEditorOnCheck(this.i, this.j);
/* 120:127 */     DebuggerUIUtil.focusEditorOnCheck(this.c, this.k.getTextField());
/* 121:128 */     DebuggerUIUtil.focusEditorOnCheck(this.f, this.l.getTextField());
/* 122:    */   }
/* 123:    */   
/* 124:    */   @NotNull
/* 125:    */   public JComponent getComponent()
/* 126:    */   {
/* 127:134 */     JPanel tmp4_1 = this.a;
/* 128:134 */     if (tmp4_1 == null) {
/* 129:134 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel", "getComponent" }));
/* 130:    */     }
/* 131:134 */     return tmp4_1;
/* 132:    */   }
/* 133:    */   
/* 134:    */   public boolean isVisibleOnPopup(@NotNull B paramB)
/* 135:    */   {
/* 136:139 */     if (paramB == null) {
/* 137:139 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel", "isVisibleOnPopup" }));
/* 138:    */     }
/* 139:139 */     JavaBreakpointProperties localJavaBreakpointProperties = (JavaBreakpointProperties)paramB.getProperties();
/* 140:140 */     if (localJavaBreakpointProperties != null) {
/* 141:141 */       return (localJavaBreakpointProperties.COUNT_FILTER_ENABLED) || (localJavaBreakpointProperties.CLASS_FILTERS_ENABLED) || (localJavaBreakpointProperties.INSTANCE_FILTERS_ENABLED);
/* 142:    */     }
/* 143:143 */     return false;
/* 144:    */   }
/* 145:    */   
/* 146:    */   public void saveTo(@NotNull B paramB)
/* 147:    */   {
/* 148:148 */     if (paramB == null) {
/* 149:148 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel", "saveTo" }));
/* 150:    */     }
/* 151:148 */     JavaBreakpointProperties localJavaBreakpointProperties = (JavaBreakpointProperties)paramB.getProperties();
/* 152:149 */     if (localJavaBreakpointProperties == null) {
/* 153:150 */       return;
/* 154:    */     }
/* 155:    */     try
/* 156:    */     {
/* 157:154 */       String str = this.j.getText().trim();
/* 158:155 */       localJavaBreakpointProperties.COUNT_FILTER = (!str.isEmpty() ? Integer.parseInt(str) : 0);
/* 159:156 */       if (localJavaBreakpointProperties.COUNT_FILTER < 0) {
/* 160:157 */         localJavaBreakpointProperties.COUNT_FILTER = 0;
/* 161:    */       }
/* 162:    */     }
/* 163:    */     catch (Exception localException) {}
/* 164:163 */     localJavaBreakpointProperties.COUNT_FILTER_ENABLED = ((localJavaBreakpointProperties.COUNT_FILTER > 0) && (this.i.isSelected()));
/* 165:164 */     b();
/* 166:165 */     a();
/* 167:166 */     a(true);
/* 168:167 */     b(true);
/* 169:    */     
/* 170:169 */     localJavaBreakpointProperties.INSTANCE_FILTERS_ENABLED = ((this.k.getText().length() > 0) && (this.c.isSelected()));
/* 171:170 */     localJavaBreakpointProperties.CLASS_FILTERS_ENABLED = ((this.l.getText().length() > 0) && (this.f.isSelected()));
/* 172:171 */     localJavaBreakpointProperties.setClassFilters(this.m);
/* 173:172 */     localJavaBreakpointProperties.setClassExclusionFilters(this.n);
/* 174:173 */     localJavaBreakpointProperties.setInstanceFilters(this.o);
/* 175:    */   }
/* 176:    */   
/* 177:    */   private static void a(JPanel paramJPanel, JComponent paramJComponent)
/* 178:    */   {
/* 179:177 */     paramJPanel.setLayout(new BorderLayout());
/* 180:178 */     paramJPanel.add(paramJComponent, "Center");
/* 181:    */   }
/* 182:    */   
/* 183:    */   public void loadFrom(@NotNull B paramB)
/* 184:    */   {
/* 185:183 */     if (paramB == null) {
/* 186:183 */       throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/jetbrains/java/debugger/breakpoints/JavaBreakpointFiltersPanel", "loadFrom" }));
/* 187:    */     }
/* 188:183 */     JavaBreakpointProperties localJavaBreakpointProperties = (JavaBreakpointProperties)paramB.getProperties();
/* 189:184 */     if (localJavaBreakpointProperties != null)
/* 190:    */     {
/* 191:185 */       if (localJavaBreakpointProperties.COUNT_FILTER > 0) {
/* 192:186 */         this.j.setText(Integer.toString(localJavaBreakpointProperties.COUNT_FILTER));
/* 193:    */       } else {
/* 194:189 */         this.j.setText("");
/* 195:    */       }
/* 196:192 */       this.i.setSelected(localJavaBreakpointProperties.COUNT_FILTER_ENABLED);
/* 197:    */       
/* 198:194 */       this.c.setSelected(localJavaBreakpointProperties.INSTANCE_FILTERS_ENABLED);
/* 199:195 */       this.k.setEnabled(localJavaBreakpointProperties.INSTANCE_FILTERS_ENABLED);
/* 200:196 */       this.k.getTextField().setEditable(localJavaBreakpointProperties.INSTANCE_FILTERS_ENABLED);
/* 201:197 */       this.o = localJavaBreakpointProperties.getInstanceFilters();
/* 202:198 */       a(true);
/* 203:    */       
/* 204:200 */       this.f.setSelected(localJavaBreakpointProperties.CLASS_FILTERS_ENABLED);
/* 205:201 */       this.l.setEnabled(localJavaBreakpointProperties.CLASS_FILTERS_ENABLED);
/* 206:202 */       this.l.getTextField().setEditable(localJavaBreakpointProperties.CLASS_FILTERS_ENABLED);
/* 207:203 */       this.m = localJavaBreakpointProperties.getClassFilters();
/* 208:204 */       this.n = localJavaBreakpointProperties.getClassExclusionFilters();
/* 209:205 */       b(true);
/* 210:    */       
/* 211:207 */       XSourcePosition localXSourcePosition = paramB.getSourcePosition();
/* 212:    */     }
/* 213:211 */     updateCheckboxes();
/* 214:    */   }
/* 215:    */   
/* 216:    */   private void a(boolean paramBoolean)
/* 217:    */   {
/* 218:215 */     ArrayList localArrayList = new ArrayList();
/* 219:216 */     for (Object localObject2 : this.o) {
/* 220:217 */       if (localObject2.isEnabled()) {
/* 221:218 */         localArrayList.add(Long.toString(localObject2.getId()));
/* 222:    */       }
/* 223:    */     }
/* 224:221 */     if (paramBoolean) {
/* 225:222 */       this.k.setText(StringUtil.join(localArrayList, " "));
/* 226:    */     }
/* 227:225 */     ??? = a(localArrayList, " ", (int)Math.sqrt(this.o.length) + 1, "\n");
/* 228:226 */     this.k.getTextField().setToolTipText((String)???);
/* 229:    */   }
/* 230:    */   
/* 231:    */   private class MyTextField
/* 232:    */     extends JTextField
/* 233:    */   {
/* 234:    */     public MyTextField() {}
/* 235:    */     
/* 236:    */     public String getToolTipText(MouseEvent paramMouseEvent)
/* 237:    */     {
/* 238:235 */       JavaBreakpointFiltersPanel.this.a();
/* 239:236 */       JavaBreakpointFiltersPanel.this.b(false);
/* 240:237 */       JavaBreakpointFiltersPanel.this.b();
/* 241:238 */       JavaBreakpointFiltersPanel.this.a(false);
/* 242:239 */       String str = super.getToolTipText(paramMouseEvent);
/* 243:240 */       return getToolTipText().length() == 0 ? null : str;
/* 244:    */     }
/* 245:    */     
/* 246:    */     public JToolTip createToolTip()
/* 247:    */     {
/* 248:245 */       JToolTip local1 = new JToolTip() {};
/* 249:248 */       local1.setComponent(this);
/* 250:249 */       return local1;
/* 251:    */     }
/* 252:    */   }
/* 253:    */   
/* 254:    */   private void a()
/* 255:    */   {
/* 256:254 */     String str = this.l.getText();
/* 257:    */     
/* 258:256 */     ArrayList localArrayList1 = new ArrayList();
/* 259:257 */     ArrayList localArrayList2 = new ArrayList();
/* 260:258 */     int i1 = -1;
/* 261:259 */     for (int i2 = 0; i2 <= str.length(); i2++) {
/* 262:260 */       if ((i2 < str.length()) && (!Character.isWhitespace(str.charAt(i2))))
/* 263:    */       {
/* 264:261 */         if (i1 == -1) {
/* 265:262 */           i1 = i2;
/* 266:    */         }
/* 267:    */       }
/* 268:266 */       else if (i1 >= 0)
/* 269:    */       {
/* 270:267 */         if (str.charAt(i1) == '-') {
/* 271:268 */           localArrayList2.add(new com.intellij.ui.classFilter.ClassFilter(str.substring(i1 + 1, i2)));
/* 272:    */         } else {
/* 273:271 */           localArrayList1.add(new com.intellij.ui.classFilter.ClassFilter(str.substring(i1, i2)));
/* 274:    */         }
/* 275:273 */         i1 = -1;
/* 276:    */       }
/* 277:    */     }
/* 278:    */     com.intellij.ui.classFilter.ClassFilter localClassFilter;
/* 279:277 */     for (localClassFilter : this.m) {
/* 280:278 */       if (!localClassFilter.isEnabled()) {
/* 281:279 */         localArrayList1.add(localClassFilter);
/* 282:    */       }
/* 283:    */     }
/* 284:282 */     for (localClassFilter : this.n) {
/* 285:283 */       if (!localClassFilter.isEnabled()) {
/* 286:284 */         localArrayList2.add(localClassFilter);
/* 287:    */       }
/* 288:    */     }
/* 289:287 */     this.m = ((com.intellij.ui.classFilter.ClassFilter[])localArrayList1.toArray(new com.intellij.ui.classFilter.ClassFilter[localArrayList1.size()]));
/* 290:288 */     this.n = ((com.intellij.ui.classFilter.ClassFilter[])localArrayList2.toArray(new com.intellij.ui.classFilter.ClassFilter[localArrayList2.size()]));
/* 291:    */   }
/* 292:    */   
/* 293:    */   private void b()
/* 294:    */   {
/* 295:292 */     String str = this.k.getText();
/* 296:    */     
/* 297:294 */     ArrayList localArrayList = new ArrayList();
/* 298:295 */     int i1 = -1;
/* 299:296 */     for (int i2 = 0; i2 <= str.length(); i2++) {
/* 300:297 */       if ((i2 < str.length()) && (Character.isDigit(str.charAt(i2))))
/* 301:    */       {
/* 302:298 */         if (i1 == -1) {
/* 303:299 */           i1 = i2;
/* 304:    */         }
/* 305:    */       }
/* 306:303 */       else if (i1 >= 0)
/* 307:    */       {
/* 308:304 */         localArrayList.add(InstanceFilter.create(str.substring(i1, i2)));
/* 309:305 */         i1 = -1;
/* 310:    */       }
/* 311:    */     }
/* 312:309 */     for (InstanceFilter localInstanceFilter : this.o) {
/* 313:310 */       if (!localInstanceFilter.isEnabled()) {
/* 314:311 */         localArrayList.add(localInstanceFilter);
/* 315:    */       }
/* 316:    */     }
/* 317:314 */     this.o = ((InstanceFilter[])localArrayList.toArray(new InstanceFilter[localArrayList.size()]));
/* 318:    */   }
/* 319:    */   
/* 320:    */   private void b(boolean paramBoolean)
/* 321:    */   {
/* 322:318 */     ArrayList localArrayList = new ArrayList();
/* 323:319 */     for (Object localObject3 : this.m) {
/* 324:320 */       if (localObject3.isEnabled()) {
/* 325:321 */         localArrayList.add(localObject3.getPattern());
/* 326:    */       }
/* 327:    */     }
/* 328:324 */     ??? = new ArrayList();
/* 329:325 */     for (Object localObject4 : this.n) {
/* 330:326 */       if (localObject4.isEnabled()) {
/* 331:327 */         ((List)???).add("-" + localObject4.getPattern());
/* 332:    */       }
/* 333:    */     }
/* 334:330 */     if (paramBoolean)
/* 335:    */     {
/* 336:331 */       ??? = StringUtil.join(localArrayList, " ");
/* 337:332 */       if (!localArrayList.isEmpty()) {
/* 338:333 */         ??? = (String)??? + " ";
/* 339:    */       }
/* 340:335 */       ??? = (String)??? + StringUtil.join((Collection)???, " ");
/* 341:336 */       this.l.setText((String)???);
/* 342:    */     }
/* 343:339 */     int i2 = (int)Math.sqrt(this.n.length + this.m.length) + 1;
/* 344:340 */     String str = a(localArrayList, " ", i2, "\n");
/* 345:341 */     if (!localArrayList.isEmpty()) {
/* 346:342 */       str = str + "\n";
/* 347:    */     }
/* 348:344 */     str = str + a((List)???, " ", i2, "\n");
/* 349:345 */     this.l.getTextField().setToolTipText(str);
/* 350:    */   }
/* 351:    */   
/* 352:    */   private static String a(List<String> paramList, String paramString1, int paramInt, String paramString2)
/* 353:    */   {
/* 354:349 */     String str1 = "";
/* 355:350 */     int i1 = 1;
/* 356:351 */     for (Iterator localIterator = paramList.iterator(); localIterator.hasNext(); i1++)
/* 357:    */     {
/* 358:352 */       String str2 = (String)localIterator.next();
/* 359:353 */       str1 = str1 + str2;
/* 360:354 */       if (localIterator.hasNext()) {
/* 361:355 */         if (i1 % paramInt == 0) {
/* 362:356 */           str1 = str1 + paramString2;
/* 363:    */         } else {
/* 364:359 */           str1 = str1 + paramString1;
/* 365:    */         }
/* 366:    */       }
/* 367:    */     }
/* 368:363 */     return str1;
/* 369:    */   }
/* 370:    */   
/* 371:    */   protected com.intellij.ide.util.ClassFilter createClassConditionFilter()
/* 372:    */   {
/* 373:    */     com.intellij.ide.util.ClassFilter local4;
/* 374:368 */     if (this.p != null) {
/* 375:369 */       local4 = new com.intellij.ide.util.ClassFilter()
/* 376:    */       {
/* 377:    */         public boolean isAccepted(PsiClass paramAnonymousPsiClass)
/* 378:    */         {
/* 379:372 */           return (JavaBreakpointFiltersPanel.this.p == paramAnonymousPsiClass) || (paramAnonymousPsiClass.isInheritor(JavaBreakpointFiltersPanel.this.p, true));
/* 380:    */         }
/* 381:    */       };
/* 382:    */     } else {
/* 383:377 */       local4 = null;
/* 384:    */     }
/* 385:379 */     return local4;
/* 386:    */   }
/* 387:    */   
/* 388:    */   protected void updateCheckboxes()
/* 389:    */   {
/* 390:383 */     boolean bool1 = true;
/* 391:384 */     if ((this.c.isSelected()) || (this.f.isSelected())) {
/* 392:385 */       bool1 = false;
/* 393:    */     }
/* 394:387 */     this.i.setEnabled(bool1);
/* 395:    */     
/* 396:389 */     boolean bool2 = this.i.isSelected();
/* 397:390 */     this.c.setEnabled(!bool2);
/* 398:391 */     this.f.setEnabled(!bool2);
/* 399:    */     
/* 400:393 */     this.j.setEditable(this.i.isSelected());
/* 401:394 */     this.j.setEnabled(this.i.isSelected());
/* 402:    */     
/* 403:396 */     this.k.setEnabled(this.c.isSelected());
/* 404:397 */     this.k.getTextField().setEditable(this.c.isSelected());
/* 405:    */     
/* 406:399 */     this.l.setEnabled(this.f.isSelected());
/* 407:400 */     this.l.getTextField().setEditable(this.f.isSelected());
/* 408:    */   }
/* 409:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.jetbrains.java.debugger.breakpoints.JavaBreakpointFiltersPanel

 * JD-Core Version:    0.7.0.1

 */